package com.gusti.turnos.services.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.gusti.turnos.model.AppointmentEvent;
import com.gusti.turnos.model.BirthdayEvent;
import com.gusti.turnos.response.rest.TurnosResponse;
import com.gusti.turnos.services.AbstractService;
import com.gusti.turnos.services.IEventService;
import com.gusti.turnos.util.MessageUtil;

/**
 * 
 * @author gusti
 *
 */
@Service
public class EventService extends AbstractService implements IEventService {

	//AppointmentEvents
	@Override
	public TurnosResponse retrieveAppointmentEvents( String sessionId, String uuid ) {

		TurnosResponse turnosResponse = new TurnosResponse();

//		turnosResponse.setErrorMessage( checkAuthenticationCredentials( sessionId, uuid ) );
//
//		if( !turnosResponse.hasError() ) {
//			List<AppointmentEvent> events = eventDao.retrieveAppointmentEvents();
//
//			if( events.isEmpty() ) {
//				turnosResponse.setErrorMessage( MessageUtil.getMessage( MessageUtil.EMPTY_RESULT ) );
//			} else {
//				turnosResponse.setSuccess( true );
//				turnosResponse.setData( events );
//			}
//		}

		return turnosResponse;
	}

	@Override
	public TurnosResponse newAppointmentEvent( String sessionId, String uuid ) {

		TurnosResponse turnosResponse = new TurnosResponse();

//		turnosResponse.setErrorMessage( checkAuthenticationCredentials( sessionId, uuid ) );
//
//		if( !turnosResponse.hasError() ) {
//			turnosResponse.setErrorMessage( checkUserAdminLevel() );
//		}
//
//		if( !turnosResponse.hasError() ) {
//			AppointmentEvent event = new AppointmentEvent();
//
//			event = (AppointmentEvent) eventDao.save( event );
//
//			if( event.isNew() ) {
//				turnosResponse.setErrorMessage( MessageUtil.getMessage( MessageUtil.ERROR_SAVE ) );
//			} else {
//				turnosResponse.setSuccess( true );
//				turnosResponse.setData( event );
//			}
//		}

		return turnosResponse;
	}

	@Override
	public TurnosResponse deleteAppointmentEvent( String sessionId, String uuid ) {

		TurnosResponse turnosResponse = new TurnosResponse();

		return turnosResponse;
	}

	//BirthdayEvents
	@Override
	public TurnosResponse retrieveBirthdayEvents( String sessionId, String uuid ) {

		TurnosResponse turnosResponse = new TurnosResponse();

//		turnosResponse.setErrorMessage( checkAuthenticationCredentials( sessionId, uuid ) );
//
//		if( !turnosResponse.hasError() ) {
//			List<BirthdayEvent> events = eventDao.retrieveBirthdayEvents();
//
//			if( events.isEmpty() ) {
//				turnosResponse.setErrorMessage( MessageUtil.getMessage( MessageUtil.EMPTY_RESULT ) );
//			} else {
//				turnosResponse.setSuccess( true );
//				turnosResponse.setData( events );
//			}
//		}

		return turnosResponse;
	}

	@Override
	public TurnosResponse newBirthdayEvent( String sessionId, String uuid ) {

		TurnosResponse turnosResponse = new TurnosResponse();

//		turnosResponse.setErrorMessage( checkAuthenticationCredentials( sessionId, uuid ) );
//
//		if( !turnosResponse.hasError() ) {
//			turnosResponse.setErrorMessage( checkUserAdminLevel() );
//		}
//
//		if( !turnosResponse.hasError() ) {
//			BirthdayEvent event = new BirthdayEvent();
//
//			event = (BirthdayEvent) eventDao.save( event );
//
//			if( event.isNew() ) {
//				turnosResponse.setErrorMessage( MessageUtil.getMessage( MessageUtil.ERROR_SAVE ) );
//			} else {
//				turnosResponse.setSuccess( true );
//				turnosResponse.setData( event );
//			}
//		}

		return turnosResponse;
	}

	@Override
	public TurnosResponse deleteBirthdayEvent( String sessionId, String uuid ) {

		TurnosResponse turnosResponse = new TurnosResponse();

		return turnosResponse;
	}
}
